package ch.ti.bfh.app.loodel.internal.security;

import ch.ti.bfh.app.loodel.domain.learningEvent.LearningEventRepository;
import ch.ti.bfh.app.loodel.domain.member.Member;

import javax.annotation.Resource;
import java.io.Serializable;

public class LearningEventOwnerPermission extends AbstractOwnerPermission {

    //Bug IN Spring Data: See http://forum.springsource.org/showthread.php?113720-No-matching-bean-when-using-custom-PermissionEvaluator-and-Spring-Data-JPA
    @Resource
    private LearningEventRepository learningEventRepository;

    @Override
    protected Member getOwner(Serializable targetDomainObjectId) {
        return learningEventRepository.getOne((String) targetDomainObjectId).getOwner();
    }

}
